package utils

import (
	"github.com/sirupsen/logrus"
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

var db *gorm.DB

type DbType = *gorm.DB

func InitSqliteDb(dbname string) {
	if dbname[:2] != "./" {
		dbname = "./" + dbname
	}
	var err error
	db, err = gorm.Open(sqlite.Open(dbname), &gorm.Config{})
	if err != nil {
		logrus.Fatalln(err)
	}
}

func GetDB() *gorm.DB {
	return db
}
